package com.hboxs.asl.wechat.utils;

import org.json.JSONObject;

import java.text.DateFormat;
import java.util.Date;
import java.util.Locale;

/**
 * Created by hboxs on 15/7/15.
 */
public final class TemplateMessageUtils {

    private final static DateFormat df = DateFormat.getDateInstance(DateFormat.DATE_FIELD, Locale.CHINESE);

    private TemplateMessageUtils() {
    }

    /**
     * 会员认证审核结果通知
     *
     * @param touser
     * @return
     */
    public static JSONObject authenticate(String touser, String result, Date date,String remark) {
        JSONObject json = null;
        try {
            String data = "{\n" +
                    "  \"touser\":\"%s\",\n" + //消息接收者
                    "  \"template_id\":\"hz_0k6L6-gwP9nYAd0k3mGuUyCZXtplNk0ZupMa1cB0\",\n" + //模板ID
                    "  \"url\":\"http://auction.hboxs.com/weChatMember/member/index.htm\",\n" + // 链接 URL
                    "  \"data\":{\n" +
                    "         \"first\": {\n" +
                    "             \"value\":\"审核申请结果通知！\",\n" +
                    "             \"color\":\"#173177\"\n" +
                    "         },\n" +
                    "         \"keyword1\":{\n" +
                    "             \"value\":\"%s\",\n" +
                    "             \"color\":\"#173177\"\n" +
                    "         },\n" +
                    "         \"keyword2\": {\n" +
                    "             \"value\":\"广州轩泉文化艺术品有限公司\",\n" +
                    "             \"color\":\"#173177\"\n" +
                    "         },\n" +
                    "         \"keyword3\": {\n" +
                    "             \"value\":\"%s\",\n" +
                    "             \"color\":\"#173177\"\n" +
                    "         },\n" +
                    "         \"remark\":{\n" +
                    "             \"value\":\"%s\",\n" +
                    "             \"color\":\"#173177\"\n" +
                    "         }\n" +
                    "  }\n" +
                    "}";
            json = new JSONObject(String.format(new String(data.getBytes("UTF-8")), touser, result, df.format(date),remark));
        } catch (Exception e) {
            e.printStackTrace();
        }
        return json;
    }

    /**
     * 预约拍品
     *
     * @param touser 接收人
     * @param expert 预约对象的认证名称
     * @param name   拍品名称
     * @return
     */
    public static JSONObject appointment(String touser,String title, String expert, String name,String remark) {
        JSONObject json = null;
        try {
            String data = "{\n" +
                    "  \"touser\":\"%s\",\n" + //消息接收者
                    "  \"template_id\":\"UzoEOne-NY2LBmwO80GdzxP06b3K9vJR_zQX3KJ8PrM\",\n" + //模板ID
                    "  \"url\":\"http://auction.hboxs.com/weChatMember/member/selSeq.htm\",\n" + // 链接 URL
                    "  \"data\":{\n" +
                    "         \"first\": {\n" +
                    "             \"value\":\"%s\",\n" +
                    "             \"color\":\"#173177\"\n" +
                    "         },\n" +
                    "         \"keyword1\":{\n" +
                    "             \"value\":\"%s\",\n" +
                    "             \"color\":\"#173177\"\n" +
                    "         },\n" +
                    "         \"keyword2\": {\n" +
                    "             \"value\":\"%s\",\n" +
                    "             \"color\":\"#173177\"\n" +
                    "         },\n" +
                    "         \"remark\":{\n" +
                    "             \"value\":\"%s\",\n" +
                    "             \"color\":\"#173177\"\n" +
                    "         }\n" +
                    "  }\n" +
                    "}";
            json = new JSONObject(String.format(new String(data.getBytes("UTF-8")), touser, title,expert, name,remark));
        } catch (Exception e) {
            e.printStackTrace();
        }
        return json;
    }


}